<template>
  <tbody>
    <tr v-for="(itme, index) in goodList" :key="index">
      <td>
        <input type="checkbox" :checked="itme.checked" @change="check(index)" />
      </td>
      <td>{{ itme.name }}</td>
      <td>{{ itme.price }}</td>
      <td>
        <button @click="red(index)">-</button> {{ itme.num }}
        <button @click="add(index)">+</button>
      </td>
      <td>{{ itme.price * itme.num }}</td>
      <td><button @click="del(index)">删除</button></td>
    </tr>
  </tbody>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    goodList: {
      type: Array,
      required: true,
    },
  },
  methods: {
    add(value) {
      this.$emit("add", value);
    },
    red(value) {
      this.$emit("red", value);
    },
    del(value) {
      this.$emit("del", value);
    },
    check(value) {
      this.$emit("ck", value);
    },
  },
};
</script>

<style scoped></style>
